package com.guawazi.base;

import android.app.Activity;
import android.support.v4.app.Fragment;
import android.widget.Toast;

/**
 * Created by Administrator on 2017/9/5 0005.
 */

public class BaseFragment extends Fragment {
    public BaseFragment(){

    }

    protected void showToast(String str){
        this.showToast(getActivity(), str);
    }

    protected void showToast(final Activity ctx, final String msg) {
        // 判断是在子线程，还是主线程
        if ("main".equals(Thread.currentThread().getName())) {
            Toast.makeText(ctx, msg, Toast.LENGTH_SHORT).show();
        } else {
            // 子线程
            ctx.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    Toast.makeText(ctx, msg, Toast.LENGTH_SHORT).show();
                }
            });
        }
    }

    @Override
    public void onResume() {
        super.onResume();
    }

    @Override
    public void onPause() {
        super.onPause();
    }
}
